package com.thti.mecool.client.adapter;

import java.util.List;

import com.threeti.mecool.mobile.interfaces.dto.CommunicationDto;
import com.thti.mecool.client.activity.R;
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CommunicationShowAdapter extends BaseAdapter {
	private Context mContext;
	private List<CommunicationDto> communications;
	
	@Override
	public boolean isEnabled(int position) {
		// TODO Auto-generated method stub
		return false;
	}

	public CommunicationShowAdapter(Context mContext,
			List<CommunicationDto> communications) {
		super();
		this.mContext = mContext;
		this.communications = communications;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return communications.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return communications.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View view =((Activity) mContext).getLayoutInflater().inflate(R.layout.mecool_communiction_first,null);
		TextView title,time,project,shop,form,name,occupation,tel,content;
		
		try {
			title=(TextView)view.findViewById(R.id.mecool_communiction_title);
			view.setTag(position);
			time=(TextView)view.findViewById(R.id.mecool_communiction_time);
			project=(TextView)view.findViewById(R.id.mecool_communiction_project);
			shop=(TextView)view.findViewById(R.id.mecool_communiction_shop);
			form=(TextView)view.findViewById(R.id.mecool_communiction_form);
			name=(TextView)view.findViewById(R.id.mecool_communiction_name);
			occupation=(TextView)view.findViewById(R.id.mecool_communiction_position);
			tel=(TextView)view.findViewById(R.id.mecool_communiction_tel);
			content=(TextView)view.findViewById(R.id.mecool_communiction_content);
			title.setText(communications.get(position).getTitle());
			time.setText(communications.get(position).getRecordDate());
			project.setText(communications.get(position).getProjName());
			shop.setText(communications.get(position).getProjStoreName());
			form.setText(communications.get(position).getType());
			name.setText(communications.get(position).getContactName());
			occupation.setText(communications.get(position).getContactPosition());
			tel.setText(communications.get(position).getContactPhoneOrOther());
			content.setText(communications.get(position).getContent());
		} catch (Exception e) { 
			// TODO: handle exception
		}
		return view;
	}

}
